package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TcomplaintDao;
import com.xy.manage.model.Tcomplaint;
import com.xy.manage.service.TcomplaintService;

@Service
@Transactional
public class TcomplaintServiceImpl extends BaseServiceImpl<Tcomplaint> implements
		TcomplaintService {
	private TcomplaintDao tcomplaintDao;

	public TcomplaintServiceImpl(TcomplaintDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.tcomplaintDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return tcomplaintDao.checkExist("Tcomplaint", paraName, paraValue);
	}

	@Override
	public List<Tcomplaint> getTcomplaint(Map<String, Object> map) {
		return tcomplaintDao.getTcomplaint(map);
	}
	@Override
	public Pagination getTcomplaintByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return tcomplaintDao.getTcomplaintByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Tcomplaint save(Tcomplaint tcomplaint) {
	//	tcomplaint.setModtime(new Date());
		if(tcomplaint.getId()==null){
			//新增
        	return super.save(tcomplaint);
		}else{
			//更新
			Tcomplaint tcomplaint1=tcomplaintDao.get(tcomplaint.getId());
			try {
				BeanUtil.copyNotNullProperties(tcomplaint1, tcomplaint);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(tcomplaint1);
		}
	}
}